<template>
  <div>
    <my-breadcrumb :items="['统计分析', '话题统计']"/>
    <div id="type" style="height: 400px;width: 100%;"></div>
    <!--<div id="style" style="height: 400px;width: 100%;"></div>-->
  </div>
</template>

<script>
import CLAZZ from '@/config/classify'
let echarts = require('echarts/lib/echarts')
require('echarts/lib/chart/bar')
require('echarts/lib/component/tooltip')
require('echarts/lib/component/legend')
require('echarts/lib/component/title')
export default {
  name: 'topic-count',
  data () {
    return {}
  },
  methods: {
    getTypeCount () {
      let styleChart = echarts.init(document.getElementById('type'), 'light')
      let option = {
        title: [
          {
            text: '话题类型统计'
          }
        ],
        legend: {},
        tooltip: {},
        dataset: {
          dimensions: ['label', '点击量', '评论量'],
          source: [
          ]
        },
        xAxis: {type: 'category'},
        yAxis: {
          name: '话题数（条）'
        },
        series: [
          {type: 'bar'},
          {type: 'bar'}
        ]
      }
      this.axios.get('/Statistics/getarticlenum?type=1')
        .then(res => {
          if (res.data.status === 1) {
            res.data.data.forEach(item => {
              option.dataset.source.push({
                label: CLAZZ.labelid[item.labelid - 1] ? CLAZZ.labelid[item.labelid - 1].name : '无类型',
                '点击量': item.clickcount,
                '评论量': item.commentcount
              })
            })
            styleChart.setOption(option)
          }
        })
    }
  },
  mounted () {
    this.getTypeCount()
  },
  created () {
  }
}
</script>

<style scoped>

</style>
